﻿#include "historydialog.h"

HistoryDialog::HistoryDialog(QWidget* parent):
    QDialog(parent)
{
    okButton = new QPushButton(QStringLiteral("确定"));
    cancelButton = new QPushButton(QStringLiteral("取消"));
    timeDateEdit = new QDateTimeEdit();
    idxEdit = new QSpinBox();

    timeDateEdit->setCalendarPopup(true);

    QHBoxLayout *settingLayout = new QHBoxLayout;
    settingLayout->addWidget(idxEdit);
    settingLayout->addWidget(timeDateEdit);
    idxEdit->setRange(1,4);
    timeDateEdit->setDisplayFormat("yyyy/MM/dd HH:00");
    timeDateEdit->setDateTime(QDateTime(QDate(2020,9,24),QTime(14,28)));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(settingLayout);
    mainLayout->addLayout(buttonLayout);
    setLayout(mainLayout);

    setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);

    connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept);
    connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject);

    setWindowTitle(QStringLiteral("设置DTU历史时间"));

}

SmallHistoryDialog::SmallHistoryDialog(QWidget* parent) :
    QDialog(parent)
{
    okButton = new QPushButton(QStringLiteral("确定"));
    cancelButton = new QPushButton(QStringLiteral("取消"));
    timeDateEdit = new QDateTimeEdit();
    timeDateEdit->setCalendarPopup(true);

    QHBoxLayout* buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addWidget(timeDateEdit);
    mainLayout->addLayout(buttonLayout);
    setLayout(mainLayout);

    setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);

    connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept);
    connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject);

    setWindowTitle(QStringLiteral("导出的注脂机日期"));
}
